package com.qf.dao.impl;

import com.qf.dao.OrderItemDao;
import com.qf.model.Goods;
import com.qf.model.OrderItem;
import com.qf.util.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.Connection;
import java.util.List;

public class OrderItemDaoImpl implements OrderItemDao {
    QueryRunner qr=new QueryRunner();
    @Override
    public List<OrderItem> selectOrderItemsByOid(String oid) {
        Connection con=null;
        List<OrderItem> list=null;
        try {
            con= JDBCUtil.getCon();
            //默认只查询上架的商品
            String sql="select * from orderitem where oid=?";
            list = qr.query(con,sql,new BeanListHandler<OrderItem>(OrderItem.class),oid);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JDBCUtil.colseCon(con);
        }
        return list;
    }
}
